package com.moli.iov.base.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.moli.iov.base.model.po.VehicleTbox;
import com.moli.iov.base.util.CollectionUtils;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;

/**
 * @author whl
 */
public class VehicleTboxParam {

  /**
   *
   */
  private QueryWrapper<VehicleTbox> queryWrapper;

  public VehicleTboxParam() {
    queryWrapper = new QueryWrapper<>();
    queryWrapper.eq("is_delete", 0);
  }

  public QueryWrapper<VehicleTbox> get() {
    return queryWrapper;
  }

  public VehicleTboxParam queryEqCompanyId(Long companyId){
    if (companyId!=null){
      queryWrapper.eq("company_id",companyId);
    }
    return this;
  }
  public VehicleTboxParam queryEqDeviceModel(String deviceModel){
    if (StringUtils.isNotEmpty(deviceModel)){
      queryWrapper.eq("device_model",deviceModel);
    }
    return this;
  }
  public VehicleTboxParam queryEqSimNo(String simNo){
    if (StringUtils.isNotEmpty(simNo)){
      queryWrapper.eq("sim_no",simNo);
    }
    return this;
  }
  public VehicleTboxParam queryEqDeviceId(String deviceId){
    if (StringUtils.isNotEmpty(deviceId)){
      queryWrapper.eq("device_id",deviceId);
    }
    return this;
  }

  public VehicleTboxParam queryEqIccid(String iccid){
    if (StringUtils.isNotEmpty(iccid)){
      queryWrapper.eq("iccid",iccid);
    }
    return this;
  }
  public VehicleTboxParam queryEqSupplierName(String supplierName){
    if (StringUtils.isNotEmpty(supplierName)){
      queryWrapper.eq("supplier_name",supplierName);
    }
    return this;
  }
  public VehicleTboxParam queryBetweenRegisterTime(Date startTime,Date endTime){
    if(startTime!=null && endTime!=null){
      queryWrapper.between("register_time",startTime,endTime);
    }
    return this;
  }
  public VehicleTboxParam queryLikeVin(String vin){
    if(!StringUtils.isEmpty(vin)){
      queryWrapper.like("vin","%"+vin+"%");
    }
    return this;
  }
  public VehicleTboxParam queryEqVin(String vin){
    if(!StringUtils.isEmpty(vin)){
      queryWrapper.eq("vin",vin);
    }
    return this;
  }
  public VehicleTboxParam queryInEqDeviceId(List<String> deviceId){
    if (!CollectionUtils.isEmpty(deviceId)){
      queryWrapper.in("device_id",deviceId);
    }
    return this;
  }
  public VehicleTboxParam queryInVin(List<String> vinList) {
    if(!CollectionUtils.isEmpty(vinList)){
      queryWrapper.in("vin",vinList);
    }
    return this;
  }
  public VehicleTboxParam queryEqAuthorizedStatus(Integer authorizedStatus) {
    if(authorizedStatus!=null){
      queryWrapper.eq("authorized_status",authorizedStatus);
    }
    return this;
  }

  /**
   * 空
   * 不等于
   * @return
   */
  public VehicleTboxParam queryNotEmptyByVin(){
    queryWrapper.ne("vin","");
    return this;
  }

}
